package com.nkzy.service.impl;

import com.nkzy.mapper.UserMapper;
import com.nkzy.pojo.User;
import com.nkzy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
//业务层完成逻辑，如果没有业务，也必须有这一层
    @Autowired
    private UserMapper userMapper;

    // 插入用户
    @Override
    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }

    // 根据ID删除用户
    @Override
    public int deleteUserById(Long id) {
        return userMapper.deleteUserById(id);
    }

    // 更新用户信息
    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    // 根据ID查询用户
    @Override
    public User selectUserById(Long id) {
        return userMapper.selectUserById(id);
    }
    // 根据多个ID查询用户
    @Override
    public List<User> selectUsersByIds(List<Long> ids) {
        return userMapper.selectUsersByIds(ids);
    }
    // 查询所有用户
    @Override
    public List<User> selectAllUsers() {
        return userMapper.selectAllUsers(null);
    }
}